home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacPerl 4.1.3 / lib / assert.pl < prev    next >
Encoding:
Text File  |  1993-10-23  |  1.2 KB  |  20 lines  |  [TEXT/MPS ]

  1. # assert.pl
  2. # tchrist@convex.com (Tom Christiansen)
  3. # Usage:
  4. #     &assert('@x > @y');
  5. #     &assert('$var > 10', $var, $othervar, @various_info);
  6. # That is, if the first expression evals false, we blow up.  The
  7. # rest of the args, if any, are nice to know because they will
  8. # be printed out by &panic, which is just the stack-backtrace
  9. # routine shamelessly borrowed from the perl debugger.
  10.  
  11. sub assert {
  12.     &panic("ASSERTION BOTCHED: $_[0]",$@) unless eval $_[0];
  13.  
  14. sub panic {
  15.     select(STDERR);